import { Injectable, Logger } from '@nestjs/common';
import { CreatePaymentInfoDto } from './dto/create-payment_info.dto';
import { UpdatePaymentInfoDto } from './dto/update-payment_info.dto';
import { InjectRepository } from '@nestjs/typeorm';
import { OrderInfo } from '../../daijia_order/order_info/entities/order_info.entity';
import { Repository } from 'typeorm';
import { PaymentInfo } from './entities/payment_info.entity';
import { SuccessResponse } from '../../../util/ResultResponse';

@Injectable()
export class PaymentInfoService {

  private readonly logger: Logger = new Logger('PaymentInfoService');

  constructor(
    @InjectRepository(PaymentInfo)
    private readonly paymentInfoRepository: Repository<PaymentInfo>,
  ) {}

  create(createPaymentInfoDto: CreatePaymentInfoDto) {
    return 'This action adds a new paymentInfo';
  }

  async findAll() : Promise<SuccessResponse<PaymentInfo[]>>  {
    return await this.paymentInfoRepository.find().then(result => {
      return {
        code: 0,
        data: result,
        message: '成功',
      };
    })
  }

  findOne(id: number) {
    return `This action returns a #${id} paymentInfo`;
  }

  update(id: number, updatePaymentInfoDto: UpdatePaymentInfoDto) {
    return `This action updates a #${id} paymentInfo`;
  }

  remove(id: number) {
    return `This action removes a #${id} paymentInfo`;
  }
}
